<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>记账簿</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="libs/handlebars.min.js">
	
</script>
<script type="text/javascript" src="libs/getQueryString.js">
	
</script>
<script src="libs/js.cookie-2.1.0.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h1 align="center">
					<strong>小刘记账</strong>
				</h1>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<ul class="nav nav-pills">
					<li><a href="index.html">首页</a></li>
					<li><a href="add2.html"><strong>新加收入</strong></a></li>
					<li><a href="add1.html"><strong>新加支出</strong></a></li>
					<li><a href="#"><strong>用户：</strong><span id="text3"></span></a>
					</li>
					<li><a href="tongji.html"><strong>统计</strong></a></li>
					<li><a href="query.html"><strong>查询</strong></a></li>
					<li class="active"><a href="#"><strong>详情</strong></a></li>
				</ul>
			</div>
		</div>
	</div>


	<div class="container">
		<div class="row">
			<div class="col-md-9">
				<div class="panel panel-warning">
					<div class="panel-heading">查询结果</div>
					<div class="panel-body" id="list1"></div>
				</div>
			</div>
		</div>
	</div>

	<script id="template" type="text/x-handlebars-template">
{{#each item}}
<div class="panel panel-default col-md-3 ">
   <div class="panel-body">
     <dl>
<dt>id</dt><dd>{{id}}</dd>
<dt>时间</dt><dd>{{date_time}}</dd>
<dt>地点</dt><dd>{{place}}</dd>
<dt>收入</dt><dd>{{money_in}}</dd>
<dt>支出</dt><dd>{{money_out}}</dd>
<dt>类别</dt><dd>{{kind}}</dd>
<dt>备注</dt><dd>{{remark}}</dd>
<button id="dele">删除</button>
     </dl>
   </div>
 </div>
{{/each}}
</script>
	<script type="text/javascript">
		$(function() {
			var id = getQueryString('id');
			$.getJSON('xiang.action?id=' + id, function(res) {
				console.log(res);
				var data = {
					'item' : res
				};
				var t = Handlebars.compile($('#template').html());
				$('#list1').html(t(data));
				$('#dele').click(function() {
					$.post('dele.action', {
						id : id

					}, function(res, status) {
						//加IF判断是否删除
						window.location.href = 'index.html';
					})
				})
			})
			$.getJSON('queryuser.action', function(res) {
				console.log(res);
				$('#text3').text(res.nickname);
			});
		})
		if (!Cookies.get("user")) {
			window.location.href = "login.html";
		}
	</script>
</body>
</html>